
const config = {
  wsUrl : "ws://127.0.0.1:8000/ws",
  socket: null,
  audioSavePath:"./sound/",
  audioType:".wav",
}



function createChatWs(url,callBack)
{
  socket = new WebSocket(config.wsUrl);
  socket.onopen = function()
  {
    console.log("opend ws")
  }
  socket.onmessage = event => {
    
    callBack && callBack(event)
  }

  socket.onclose = () => {
    console.log("close ws")
  };
}



function closeChatWs()
{
  if(socket)
  {
    socket.close();
  }
}

export { createChatWs }